;;; +counsel.el --- Initialization and mode setting.

;;; Homepage:
;; https://github.com/abo-abo/swiper#counsel

;;; Commentary:
;; A set of improved `ivy-mode' commands.

;;; Code:

(use-package counsel
  :ensure
  :bind
  (:map counsel-mode-map
	([remap centaur-tabs-switch-group] . centaur-tabs-counsel-switch-group)
	([remap list-buffers] . counsel-switch-buffer-other-window)
	([remap flycheck-list-errors] . counsel-flycheck)
	("C-x b" . counsel-switch-buffer)
	("C-x C-t" . counsel-load-theme)
	("C-h C-c" . counsel-colors)
	("C-h C-f" . counsel-faces)
	("M-s a" . counsel-ag))
  :init
  (setq ivy-sort-functions-alist '((counsel-M-x . ivy-string<)
				   (counsel-ag . ivy-string<)
				   (counsel-apropos . ivy-string<)
				   (counsel-bookmark . ivy-string<)
				   (counsel-cd . ivy-string<)
				   (counsel-colors-emacs . ivy-string<)
				   (counsel-colors-web . ivy-string<)
				   (counsel-descbinds . ivy-string<)
				   (counsel-describe-face . ivy-string<)
				   (counsel-describe-function . ivy-string<)
				   (counsel-describe-symbol . ivy-string<)
				   (counsel-describe-variable . ivy-string<)
				   (counsel-dired . ivy-string<)
				   (counsel-dired-jump . ivy-string<)
				   (counsel-faces . ivy-string<)
				   (counsel-file-jump . ivy-string<)
				   (counsel-file-jump-from-find . ivy-string<)
				   (counsel-find-file . ivy-string<)
				   (counsel-find-file-extern . ivy-string<)
				   (counsel-find-file-from-jump . ivy-string<)
				   (counsel-find-file-undo . ivy-string<)
				   (counsel-find-library . ivy-string<)
				   (counsel-imenu . ivy-string<)
				   (counsel-info-lookup-symbol . ivy-string<)
				   (counsel-list-processes . ivy-string<)
				   (counsel-load-library . ivy-string<)
				   (counsel-load-theme . ivy-string<)
				   (counsel-package . ivy-string<)
				   (counsel-projectile . ivy-string<)
				   (counsel-projectile-find-dir . ivy-string<)
				   (counsel-projectile-find-file . ivy-string<)
				   (counsel-projectile-switch-project . ivy-string<)
				   (counsel-projectile-switch-to-buffer . ivy-string<)
				   (counsel-set-variable . ivy-string<)
				   (counsel-switch-buffer . ivy-string<)
				   (counsel-switch-buffer-other-window . ivy-string<)
				   (customize-group . ivy-string<))
	counsel-preselect-current-file t
	counsel-find-file-at-point t)

  (counsel-mode t))

(provide '+counsel)

;;; +counsel.el ends here
